home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gxmatrix.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  76 lines

  1. /* Copyright (C) 1989, 1990, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gxmatrix.h */
  20. /* Internal matrix routines for Ghostscript library */
  21.  
  22. #ifndef gxmatrix_INCLUDED
  23. #  define gxmatrix_INCLUDED
  24.  
  25. #include "gsmatrix.h"
  26.  
  27. /* A matrix with a cached fixed-point copy of the translation. */
  28. /* This is only used by a few routines; they are responsible */
  29. /* for ensuring the validity of the cache */
  30. /* (by calling gs_update_matrix_fixed). */
  31. typedef struct gs_matrix_fixed_s {
  32.     _matrix_body;
  33.     fixed tx_fixed, ty_fixed;
  34. } gs_matrix_fixed;
  35. extern    void    gs_update_matrix_fixed(P1(gs_matrix_fixed *));
  36.  
  37. /* Coordinate transformations to fixed point. */
  38. int    gs_point_transform2fixed(P4(const gs_matrix_fixed *, floatp, floatp, gs_fixed_point *)),
  39.     gs_distance_transform2fixed(P4(const gs_matrix_fixed *, floatp, floatp, gs_fixed_point *));
  40.  
  41. /* Macro for testing whether matrix coefficients are zero, */
  42. /* for shortcuts when the matrix has no skew. */
  43. #define is_skewed(pmat) !is_fzero2((pmat)->xy, (pmat)->yx)
  44.  
  45. /*
  46.  * Define the fixed-point coefficient structure for avoiding
  47.  * floating point in coordinate transformations.
  48.  * Currently this is used only by the Type 1 font interpreter.
  49.  * The setup is in gscoord.c.
  50.  */
  51. typedef struct {
  52.     long l;
  53.     fixed f;
  54. } coeff1;
  55. typedef struct {
  56.     coeff1 xx, xy, yx, yy;
  57.     int skewed;
  58.     int shift;            /* see m_fixed */
  59.     int max_bits;            /* max bits of coefficient */
  60.     fixed round;            /* ditto */
  61. } fixed_coeff;
  62. /*
  63.  * Multiply a fixed whose integer part usually does not exceed max_bits
  64.  * in magnitude by a coefficient from a fixed_coeff.
  65.  * We can use a faster algorithm if the fixed is an integer within
  66.  * a range that doesn't cause the multiplication to overflow an int.
  67.  */
  68. #define m_fixed(v, c, fc, maxb)\
  69.   (((v) + (fixed_1 << (maxb - 1))) &\
  70.     ((-fixed_1 << maxb) | _fixed_fraction_v) ?    /* out of range, or has fraction */\
  71.    (fixed2int_var(v) * (fc).c.f +\
  72.     arith_rshift(fixed_fraction(v) * (fc).c.f + fixed_half, _fixed_shift)) :\
  73.    arith_rshift(fixed2int_var(v) * (fc).c.l + (fc).round, (fc).shift))
  74.  
  75. #endif                    /* gxmatrix_INCLUDED */
  76.